﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SAC.Helper;
using BLL;

public partial class Admin_Default2 : System.Web.UI.Page
{
    string dbType = "";
    string RTDBType = "";
    string dbName = "";
    string dbUser = "";
    string dbPwd = "";
    string dbIP = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dbType = IniHelper.ReadIniData("RelationDBbase", "DBType", null);
            dbIP = IniHelper.ReadIniData("RelationDBbase", "DBIP", null);
            dbName = IniHelper.ReadIniData("RelationDBbase", "DBName", null);
            dbUser = IniHelper.ReadIniData("RelationDBbase", "DBUser", null);
            dbPwd = IniHelper.ReadIniData("RelationDBbase", "DBPwd", null);

            this.drpDB.SelectedValue = dbType;

            if (dbIP != "")
                this.txtDBip.Text = dbIP;
            if (dbName != "")
                this.txtDBName.Text = dbName;
            if (dbUser != "")
                this.txtDBUser.Text = dbUser;
            if (dbPwd != "")
                this.txtDBPwd.Text = dbPwd;

            if (IniHelper.ReadIniData("RTDB", "DBType", null) != "")
                this.drpRTDB.SelectedValue = IniHelper.ReadIniData("RTDB", "DBType", null);

            this.txtRTDBip.Text = IniHelper.ReadIniData("RTDB", "DBIP", null);
            this.txtRTDBPort.Text = IniHelper.ReadIniData("RTDB", "DBPort", null);
            this.txtRTDBUser.Text = IniHelper.ReadIniData("RTDB", "DBUser", null);
            this.txtRTDBPwd.Text = IniHelper.ReadIniData("RTDB", "DBPwd", null);
            this.txtHisName.Text = IniHelper.ReadIniData("RTDB", "DBHisName", null);
            this.txtProxyIpPort.Text = IniHelper.ReadIniData("RTDB", "ProxyIpPort", null);
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.drpDB.SelectedValue == "DB2")
            dbType = "DB2";
        else
            dbType = "SQL";

        dbIP = this.txtDBip.Text;
        dbName = this.txtDBName.Text;
        dbUser = this.txtDBUser.Text;
        dbPwd = this.txtDBPwd.Text;

        IniHelper.WriteIniData("RelationDBbase", "DBType", dbType);
        IniHelper.WriteIniData("RelationDBbase", "DBIP", dbIP);
        IniHelper.WriteIniData("RelationDBbase", "DBName", dbName);
        IniHelper.WriteIniData("RelationDBbase", "DBUser", dbUser);
        IniHelper.WriteIniData("RelationDBbase", "DBPwd", dbPwd);

        IniHelper.WriteIniData("RTDB", "DBType", this.drpRTDB.SelectedValue);
        IniHelper.WriteIniData("RTDB", "DBIP", this.txtRTDBip.Text);
        IniHelper.WriteIniData("RTDB", "DBPort", this.txtRTDBPort.Text);
        IniHelper.WriteIniData("RTDB", "DBUser", this.txtRTDBUser.Text);
        IniHelper.WriteIniData("RTDB", "DBPwd", this.txtRTDBPwd.Text);
        IniHelper.WriteIniData("RTDB", "DBHisName", this.txtHisName.Text);
        IniHelper.WriteIniData("RTDB", "ProxyIpPort", this.txtProxyIpPort.Text);



    }
}
